package model.information;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Observable;

/**
 * A class that represents an entry in a journal or diary.
 * @author Tobias Møller Kjærsgaard
 * @author Hjalte Blichfeldt Flyger
 * @author Gitte Simonsen
 * @author Claus Lund
 */
public class JournalEntry extends Observable implements Serializable{
    private Calendar date;
    private String title;
    private String text;

    public JournalEntry(String title, String text) {
        this.title = title;
        this.text = text;
        this.date = Calendar.getInstance();
    }

    public Calendar getDate() {
        return date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
        this.setChanged();
        this.notifyObservers("journalentry");
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
        this.setChanged();
        this.notifyObservers("journalentry");
    }

    @Override
    public String toString() {
        return date.get(Calendar.DATE) + "-" + (int)(date.get(Calendar.MONTH) + 1) + "-" +date.get(Calendar.YEAR);
    }


}
